package org.kjtc.controller;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.kjtc.service.TestService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/**
 * @ Author     ：Yellowong
 * @ Date       ：Created in 11:11 2018/12/19
 * @ Description：
 */
@Controller
public class TestController {

    @Autowired
    private TestService testService;

    /* 测试数据 */
    @RequestMapping("/getAllTestData")
    @ResponseBody
    public Object getAllTestData(
            @RequestParam(value = "pageNumber", defaultValue = "1") Integer pageNumber,
            @RequestParam(value = "pageSize", defaultValue =  "10") Integer pageSize) {

        PageHelper.startPage(pageNumber, pageSize);

        List testList = testService.getAllTestData();

        PageInfo pageInfo = new PageInfo(testList);

        return pageInfo;

    }

    @RequestMapping("/getTestDataWithCertainNum")
    @ResponseBody
    public Object getTestDataWithCertainNum(
            @RequestParam(value = "num", defaultValue =  "5") Integer num) {

        List testList = testService.getTestDataWithCertainNum(num);

        return testList;

    }
}
